<?php
session_start();
include '../../../inc/reuse/dbconfig.php';
$username = $_POST['username'];
$password = md5($_POST['password']);
$sql = "SELECT * FROM webmaster WHERE webmaster_username='$username' and webmaster_password ='$password'"; //ตรวจสอบ username และ password ตรงกันใหม
$exc = mysql_query($sql);
$num_rows = mysql_num_rows($exc);

if($num_rows > 0){
	// ถ้าตรงกันก็เก็บ session
	$row = mysql_fetch_array($exc);	
	$_SESSION['username'] = $row['webmaster_username'];
	$_SESSION['uid'] = $row['webmaster_id'];
	header("location: ../../admin.php"); //เข้าไปหน้าหลักของ admin
}
else 
{
	echo "dsfsdf";
	$code_error="<BR><FONT COLOR=\"red\">Wrong username & Password.</FONT>";
	$_SESSION['code_error'] = $code_error;
	header("location: ../../index.php"); //รหัสผ่านผิดกลับไปยังหน้า log in
}

?>